package com.example.lambda.reactor;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

public class FirstReactorDemo {
    public static void main(String[] args) {
        //测试Flux
        Flux.just(1, 2, 3, 4, 5, 6).subscribe(System.out::print);
        System.out.println();
        System.out.println("测试Flux-----------------------------");

        //测试Mono
        Mono.just(1).subscribe(System.out::print);
        System.out.println();
        System.out.println("测试Mono-----------------------------");

        //测试2个参数的subscribe方法
        Flux.just(1, 2, 3, 4, 5, 6).subscribe(System.out::print, System.err::print);
        System.out.println();
        System.out.println("测试2个参数的subscribe方法-----------------------------");

        //测试3个参数的subscribe方法
        Flux.just(1, 2, 3, 4, 5, 6).subscribe(System.out::print, System.err::print, () -> System.out.print("complete"));
        System.out.println();
        System.out.println("测试3个参数的subscribe方法-----------------------------");

        //测试4个参数的subscribe方法
        Flux.just(1, 2, 3, 4, 5, 6).subscribe(System.out::print, System.err::print, () -> System.out.println("complete"), subscription -> {
            System.out.println("订阅发生了");
            subscription.request(10);
        });
        System.out.println("测试4个参数的subscribe方法-----------------------------");
    }
}
